/**
 * creation: 22-apr-2008
 */
package org.jfonia.connect.logic;

import org.jfonia.connect.BasicNode;
import org.jfonia.connect.Callable;
import org.jfonia.connect.Value;

/**
 * @author wijnand.schepens@gmail.com
 *
 */
public class While extends BasicNode
{
	protected Value<Boolean> condition;
	protected Callable       body;
	
	public While(Value<Boolean> condition, Callable body)
	{
		this.condition = condition;
		this.body = body;
	}
	

	/**
	 * Calls 'body' while 'condition' evaluates to true. 'this' used as parameter to call().
	 * 
	 * @param param
	 * @return always returns true 
	 */
	public boolean callThis(Object param)
	{
		while (condition.get().booleanValue())
			body.call(this);
		return true;		// TODO: ok?
	}
		
}
